package pub.guoxin.oops.manager.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pub.guoxin.oops.annotation.InjectUser;
import pub.guoxin.oops.constants.OopsPathConstants;
import pub.guoxin.oops.manager.service.AlarmInfoService;
import pub.guoxin.oops.model.User;
import pub.guoxin.oops.vo.ResultVo;
import pub.guoxin.oops.vo.ResultVoBuilder;

import java.util.Map;

/**
 * Create by guoxin on 2018/5/5
 */
@RestController
@RequestMapping(OopsPathConstants.ALARM_INFO_PATH)
public class AlarmInfoController {

    @Autowired
    private ResultVoBuilder builder;
    @Autowired
    private AlarmInfoService alarmInfoService;

    @PreAuthorize(value = "hasAnyRole('ADMIN, USER')")
    @ApiOperation(value = "预警处理分页", notes = "预警处理分页（权限：公司管理员）")
    @GetMapping(value = "/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultVo register(@InjectUser User user, String alarmDisposeId) {
        Map<String, Object> statistics = alarmInfoService.statistics(alarmDisposeId);
        return builder.buildSuccessResultInfo(statistics);
    }

}
